//发布者客户端
#include "mq_connection.hpp"
int main()
{
    //服务端地址信息，异步线程池
    //1.实例化异步工作线程池对象
    bitmq::AsyncWorker::ptr awp= std::make_shared<bitmq::AsyncWorker>();
    //2.实例化连接对象
    bitmq::Connection::ptr conn= std::make_shared<bitmq::Connection>("43.138.76.197",8888,awp);
    //3.通过连接创建信道
    bitmq::Channel::ptr channel=conn->openChannel();
    //4.通过信道提供的服务完成所需
    google::protobuf::Map<std::string,std::string> tmp_map;
    // 1.声名一个交换机,类型为广播模式
    channel->declareExchange("exchange1",bitmq::ExchangeType::FANOUT,true,false,tmp_map);
    // 2。队列queue1
    channel->declareQueue("queue1",true,false,false,tmp_map);
    //3.队列queue2
    channel->declareQueue("queue2",true,false,false,tmp_map);
    //  4. 绑定queue1-exchange1，且binding_key设置为queue1
    channel->queueBind("exchange1","queue1","queue1");
    //  5. 绑定queue2-exchange1，且binding_key设置为news.music.#
    channel->queueBind("exchange1","queue2","news.music.#");
    //5.循环向交换机发布消息’
    for (int i = 0; i < 10; i++) {

        channel->basicPublish("exchange1", nullptr, "Hello World-" + std::to_string(i));
    }
    //6.关闭信道
    conn->closeChannel(channel);

}